﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Layout;
using DevExpress.ExpressApp.Model.NodeGenerators;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Templates;
using DevExpress.ExpressApp.Utils;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;

namespace aztall.Module.Controllers
{
    // remove Delete 
    public partial class Config_Controller : ViewController
    {
        public Config_Controller()
        {
            InitializeComponent();
            // Target required Views (via the TargetXXX properties) and create their Actions.
            this.TargetViewId = "Config_ListView;Config_DetailView";
        }
        protected override void OnActivated()
        {
            base.OnActivated();
            // Perform various tasks depending on the target View.

            // remove Delete action		
            this.Frame.GetController<DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController>().DeleteAction.Enabled.SetItemValue("", false);
            this.Frame.GetController<DevExpress.ExpressApp.SystemModule.NewObjectViewController>().NewObjectAction.Enabled.SetItemValue("", false);
            if (View.Id == "Config_ListView")
            {
                ListView view = View as ListView;
                view.CollectionSource.Criteria["NonInternal"] = CriteriaOperator.Parse("ConfigGroup <> 1");
            }

        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            // Access and customize the target View control.
        }
        protected override void OnDeactivated()
        {
            // Unsubscribe from previously subscribed events and release other references and resources.
            base.OnDeactivated();
        }
    }
}
